<?php
              
              include "classes/db/dbmanager.php";
              $pDatabase = Database::getInstance();
              $teamId = isset($_GET['id'])?$_GET['id']:'-1';
              $sql="SELECT * FROM team WHERE id = ".$teamId;
              $result = $pDatabase->query($sql);
              $isNewTeam = true;
              if ($row = mysql_fetch_array($result)) {
              	$isNewTeam = false;
              	$teamName = $row["teamName"];
              	$letterId = $row["letterId"];
              } else {
              	
              }
              ?>
<h2><?php echo ($isNewTeam ? "Új csapat": $teamName)?><h2>
<br/>
<form class="form-horizontal" action="classes/db/insertteam.php" method="post">
	 <input type="hidden" id="teamId" name="teamId" value="<?php echo ($teamId)?>">
  <div class="control-group">
    <label class="control-label" for="letterid">Kezdőbetű</label>
    <div class="controls">
      <select name="letterid" id="letterid">
      <?php
              
              $sql="SELECT * FROM letters ORDER BY letter";
              $result = $pDatabase->query($sql);
              while($row = mysql_fetch_array($result)) {
              	echo "<option value=\"".$row["id"]."\" ".($letterId==$row["id"] ? "selected" : "").">".$row["letter"]."</option>";
              }
              ?>
	</select>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label" for="teamName">Csapat neve</label>
    <div class="controls">
      <input type="text" id="teamName" name="teamName" value="<?php echo ($isNewTeam ? "": $teamName)?>">
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
      <button type="submit" class="btn">Mentés</button>
    </div>
  </div>
</form>